<?php

use yii\helpers\Html;
use kartik\grid\GridView;
//\backend\assets\SearchAsset::register($this);
/* @var $this yii\web\View */
/* @var $searchModel app\modules\lenders\models\LenderQuery */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Lenders';
$this->params['breadcrumbs'][] = $this->title;
?>

<!--<style>
    html {overflow-y:hidden; }
</style>-->
<div class="lender-index">
    <input type="hidden" id="ids" value=''>
    <?php echo $this->render('_searchlender', ['model' => $searchModel]); ?>

    <p>
    </p>
    <?=
    GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
//         'options' => [
//            'class' => 'grid-view table-responsive'
//        ],
//        'layout' => '{summary} {items} {pager}',
        'columns' => [
            ['class' => 'yii\grid\CheckboxColumn'],
//            ['class' => 'yii\grid\SerialColumn'],
            'lenderID',
            'userName',
            'phone',
            'IDType',
            'custSeqNo',
        // 'email:email',
        ],
        'responsive' => true,
        'hover' => true,
        'pjax' => true,
    ]);
    ?>

</div>
<?php
$js = <<< JS
	var checked=$('input[name="selection[]"]:checked');
//	   var value = 0;
       var array=[];
        $.each(checked, function (i, j) {
            var row = $(j).parent().siblings();
    	value = $(row[0]).html();
    	array.push(value);
            });
//       window.parent.document.getElementById('cust-btn-ok').setAttribute('attrs', array); 
//
//            }; 
        
//        var oThead = document.getElementsByTagName('thead')[0];
//        var all = oThead.getElementsByClassName('select-on-check-all')[0];
//        //console.log(all)
//        var oTbody = document.getElementsByTagName('tbody')[0];
//       // console.log(oTbody)
//        var oChecked = oTbody.getElementsByTagName('input');
//       // console.log(oChecked)
//        var array=[];
//       
//        for(var i=0;i<oChecked.length;i++){
//            fn(i);
//         }
//          function fn(i){
//             oChecked[i].onclick = function(){
//             //console.log(oChecked[i])
//             var row = oChecked[i].parentNode.parentNode.children;
//            // console.log(row)
//            var value = row[1].innerHTML;
//              array.push(value);
//               window.parent.document.getElementById('cust-btn-ok').setAttribute('attrs', array); 
//         }
        //全选
//        all.onclick = function(){
//          
//            for(var i=0;i<oChecked.length;i++){
//               fn(i);
//             }
         
//        console.log(array)
//        }
//        
//            }
        window.parent.document.getElementById('cust-btn-ok').setAttribute('attrs', row); 
        
         
JS;

// register javascript
$this->registerJs($js);
?>
